﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Data;
using System.Web.Script.Serialization;

namespace CMD.BAL.SOL
{
    [DataContractAttribute]
    public class ObjectWeb
    {
        [DataMemberAttribute(EmitDefaultValue = false)]
        public string obj;
        public static string GetDataObject(string unid_rol)
        {
            string mensaje = "";
            try
            {
                
                 Dictionary<string, Dictionary<string, string>> parametros = new Dictionary<string, Dictionary<string, string>>();
                 DataTable dt = CMD_WEB.DAL.SrvDB.ExecuteQuery("exec SP_CMD_GET_OBJECT_WEB'" + unid_rol + "'");
                 if (dt.Rows.Count == 0)
                 {
                    return mensaje="no hay datos";
                 }
                 else
                 {
                     int i = 0;
                     foreach (DataRow rw in dt.Rows)
                     {
                         Dictionary<string, string> parametros2 = new Dictionary<string, string>();
                         parametros2.Add("edit", rw[1].ToString());
                         parametros.Add(dt.Rows[i][0].ToString(), parametros2);
                         i++;
                     }
                 }
                  // convierto el diccionario a json
                  JavaScriptSerializer ms2 = new JavaScriptSerializer();
                  string json2 = ms2.Serialize(parametros);
                  return json2;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public ObjectWeb()
        {
            
        }
        public ObjectWeb(string obj)
        {
            this.obj = obj;
        }

    }
}
